evtd
Event delegation with native events and extended events in a small library.
(Only 300 lines of codes)
Docs
evtd
Basic Usage
import { on, off } from 'evtd'
function handleClick () {
console.log('click')
}
on(window, 'click', handleClick)
on(document, 'click', handleClick)
on(eventTarget, 'click', handleClick)
on(eventTarget, 'clickoutside', handleClick)
on(eventTarget, 'mousemoveoutside', handleClick)
const handleClick2 = () => console.log('click2')
on(eventTarget, 'click', handleClick2)
off(eventTarget, 'click', handleClick2)
on(eventTarget, 'click', handleClick2, true)
off(eventTarget, 'click', handleClick2, true)
License
MIT
Inspired by delegated-events